<?php
namespace app\api\controller;

class AccessToken extends Base
{
    /**
  * AccessToken 保留时间2小时  7200
  * @return mixed
  */
    public function getAccessToken(){
        $config = cache('db_config_data');
        $access_token_url = "https://api.weixin.qq.com/cgi-bin/token?" .
        "grant_type=client_credential&appid=%s&secret=%s";
        $wxAppID =  $config['app_id'];
        $wxAppSecret = $config['app_secret'];
        $wxAccessTokenUrl = sprintf(
            $access_token_url, $wxAppID, $wxAppSecret);
        //     $result = curl_get($wxAccessTokenUrl);
        //     //$wxAccessToken = json_decode($result,true);
        //     return $result;
        $res = json_decode(file_get_contents($wxAccessTokenUrl),true);

        $access_token = $res['access_token'] ;
        return $access_token;
    }
}